package cc.rengu.redp.bizimpl.igas.controller;


import cc.rengu.redp.bizimpl.igas.service.IMchntOrderInfoService;
import cc.rengu.redp.bizimpl.igas.service.PSrcTxnAuthCfgService;
import cc.rengu.redp.bizimpl.igas.vo.MchntOrderInfoVO;
import cc.rengu.redp.bizimpl.upmp.domain.UpmpBMchntBaseInfo;
import cc.rengu.redp.bizimpl.upmp.service.IUpmpBMchntBaseInfoService;
import cc.rengu.redp.common.annotation.Log;
import cc.rengu.redp.common.controller.BaseController;
import cc.rengu.redp.common.domain.QueryRequest;
import cc.rengu.redp.common.exception.RedpException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author guohaocong
 */
@Api(tags = "业务查询:交易查询")
@RestController
@Slf4j
@RequestMapping("/admin/igas/mchntOrderReport")
public class MchntOrderInfoController extends BaseController {

    @Autowired
    private IMchntOrderInfoService mchntOrderInfoService;
    @Autowired
    private IUpmpBMchntBaseInfoService upmpBMchntBaseInfoService;

    @Autowired
    private PSrcTxnAuthCfgService pSrcTxnAuthCfgService;

    @Log("分页")
    @GetMapping("/findByPage")
    public Map<String, Object> findByPage(QueryRequest request, MchntOrderInfoVO mchntOrderInfoVO, String userId) throws RedpException {
        return getDataTable(mchntOrderInfoService.findByPage(request, mchntOrderInfoVO, userId));
    }

    /**
     * 商户名称查找
     *
     * @param request
     * @return
     */
    @Log("商户名称列表查找")
    @GetMapping("/mchntBaseInfoListByName")
    @ApiImplicitParam(paramType = "query", name = "q", value = "条件", dataType = "String")
    public Map<String, Object> mchntBaseInfoListByName(QueryRequest request, UpmpBMchntBaseInfo upmp) {
        return upmpBMchntBaseInfoService.findMchntBaseInfoListByName(request, upmp);
    }

    /**
     * 二级商户查找
     *
     * @param request
     * @param q
     * @return
     */
    @Log("二级商户列表查找")
    @GetMapping("/mchntBaseInfoListByNo")
    @ApiImplicitParam(paramType = "query", name = "q", value = "条件", dataType = "String")
    public Map<String, Object> mchntBaseInfoListByNo(QueryRequest request, String q) {
        return upmpBMchntBaseInfoService.mchntBaseInfoListByNo(request, q);
    }

    /**
     * 交易类型
     *
     * @param request
     * @param q
     * @return
     */
    @Log("交易类型列表查找")
    @GetMapping("/srcTxnInfoList")
    @ApiImplicitParam(paramType = "query", name = "q", value = "条件", dataType = "String")
    public Map<String, Object> srcTxnInfoList(QueryRequest request, String q) {
        return pSrcTxnAuthCfgService.srcTxnInfoList(request, q);
    }

    /**
     * 交易状态
     *
     * @param request
     * @param q
     * @return
     */
    @Log("交易状态列表查找")
    @GetMapping("/txnStatusList")
    @ApiImplicitParam(paramType = "query", name = "q", value = "条件", dataType = "String")
    public Map<String, Object> txnStatusList(QueryRequest request, String q) {
        Map<String, Object> maps = new HashMap<String, Object>();
        Map<String, String> map = new HashMap<String, String>();
        List<Object> list = new ArrayList<Object>();
        map = new HashMap<String, String>();
        map.put("name", "业务处理成功");
        map.put("id", "00");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "业务处理中");
        map.put("id", "01");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "业务处理失败");
        map.put("id", "02");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "付款中");
        map.put("id", "03");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "已撤销");
        map.put("id", "10");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "已部分撤销");
        map.put("id", "11");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "已冲正");
        map.put("id", "20");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "已部分冲正");
        map.put("id", "21");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "已全额退货");
        map.put("id", "30");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "已部分退货");
        map.put("id", "31");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "未确认收货全额退货");
        map.put("id", "32");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "未确认收货部分退货");
        map.put("id", "33");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "授权未完成");
        map.put("id", "40");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "授权已完成");
        map.put("id", "41");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "已确认收货");
        map.put("id", "50");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "卡券已核销");
        map.put("id", "51");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "已退汇");
        map.put("id", "60");
        list.add(map);
        map = new HashMap<String, String>();
        map.put("name", "已清算");
        map.put("id", "99");
        list.add(map);
        maps.put("results", list);
        maps.put("more", false);
        return maps;
    }


    /**
     * 收银员
     *
     * @param request
     * @param q
     * @return
     */
    @Log("交易类型列表查找")
    @GetMapping("/userInfoList")
    @ApiImplicitParam(paramType = "query", name = "q", value = "条件", dataType = "String")
    public Map<String, Object> userInfoList(QueryRequest request, String q) {
        return mchntOrderInfoService.getUserInfoList(request, q);
    }

}
